<div id="ppTipenven" class="reveal-modal">
    <div class="wrap-pp wrap-tipenven">
        <form id="tell_friend" action="<?php echo str_replace('&', '&amp;', $action); ?>" method="post" enctype="multipart/form-data">
            <h4>Tip en ven</h4>
            <p><i>Felter markeret med * skal udfyldes</i></p>

            <input type="text" id="email_from" class="txtInput" name="email_from" placeholder="Din e-mail *"/>
            <input type="text" id="email_to" class="txtInput" name="email_to" placeholder="Din ven´s e-mail *"/>
            <textarea id="tf_message" class="txtArea" name="message" placeholder="Jeg fandt dette produkt og tror at det kunne have interesse for dig."></textarea>

            <a id="send_email" class="btn btnSend" href="#">Send</a>
            <a id="reset_value" class="btn btnNustil" href="#">Nustil</a>
        </form>

        <p id="tell_friend_error" style="display:none; clear:both;"></p>
    </div>
    <!--wrap-nyhedsbrev-->
    <a class="close-reveal-modal">&#215;</a>
</div>
<!--#ppTipenven-->

<script type="text/javascript">
//<![CDATA[
	//var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;   
	var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,6})+$/;
	var msg = 'Indtast venligst en gyldig e-mail adresse'; 	
	
	jQuery('#tell_friend_btn').click(function(){
        var message = 'Jeg fandt dette produkt og tror at det kunne have interesse for dig. \n\n' + window.location.href;

        jQuery('#tf_message').val(message);
	});
	
	jQuery('#send_email').click(function(event){
		event.preventDefault();
		var error = false;
		
		if((jQuery('#email_from').val() == '') || !mail_filter.test(jQuery('#email_from').val())){
			error = true;	
			jQuery('#email_from').addClass('errorField'); 				
		}	
		
		if((jQuery('#email_to').val() == '') || !mail_filter.test(jQuery('#email_to').val())){
			error = true;	
			jQuery('#email_to').addClass('errorField');
		}
		   				
		if(error){
			jQuery('#tell_friend_error').html('<h3>' + msg + '</h3>');
		}
		else {
			jQuery('#tell_friend_error').html('');	
			
			jQuery.ajax({
	            type: 'post',
	            url: '<?php echo $send; ?>',
	            dataType: 'html',
	            data: {
					'email_from': jQuery('#email_from').val(), 
					'email_to': jQuery('#email_to').val(), 
					'url': window.location.href,
					'message': jQuery('#tf_message').val()
					//String(document.location).toLowerCase()
				},
	            success: function(html){
	                jQuery('#ppTipenven a.close-reveal-modal').trigger('click');
	            },    
	            complete: function(){
            	}
	        });    			
		}
	});
	
	jQuery('#reset_value').click(function(event){
		event.preventDefault();
		
		jQuery('#tell_friend input').each(function(){
			jQuery(this).val('');
			if(jQuery(this).hasClass('errorField')){
				jQuery(this).removeClass('errorField');
			}
		});	
		jQuery('#tell_friend_error').html('');	
	});	
//]]>
</script>